package com.ygu.mylist.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DataBaseHelper extends SQLiteOpenHelper {
	//定义数据库名称、数据库版本静态final变量，在调用父类的构造方法时传递过去
	private static final String DATABASE_NAME = "list.db";
	private static final int DATABASE_VERISON = 1;
	private static final String LIST = "LIST";
	
	public DataBaseHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERISON);
	}

	@Override
	//创建LIST表，该方法在getReadableDataBases()或getWritableDataBase()方法时调用
	public void onCreate(SQLiteDatabase db) {
		String CREATETABLE_LIST = "CREATE TABLE "
				+LIST+ "("+"id INTEGER PRIMARY KEY,"+
						"content varchar(200) NOT NULL,"+
				        "remind_time varchar(20),"+
						"status int(2)"+")";
		db.execSQL(CREATETABLE_LIST);
	}

	@Override
	//更新表结构
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		String check = "DROP TABLE IF EXISTS "+LIST;
		db.execSQL(check);
		onCreate(db);
		
	}

}
